﻿<template>
	<div class="xuanKe-container">
		<el-dialog v-model="isShowDialog" draggable="" fullscreen>
			<template #header>
				<div style="color: #fff">
					<!--<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>-->
					<span>
						{{ props.title }}
					</span>
				</div>
			</template>
			<el-row class="row-con">
				<el-col :span="24">
					<el-table
					:data="tableData"
					style="width: 100%"
					v-loading="loading"
					tooltip-effect="light"
					row-key="id"
					border="">
						<el-table-column prop="studentIdXh" label="学号" width="60" show-overflow-tooltip="">
						<template #default="scope">
							<span>{{scope.row.studentIdXh}}</span>
						</template>
						</el-table-column>
						
						<el-table-column prop="studentIdName" label="学生" width="80" show-overflow-tooltip="">
						<template #default="scope">
							<span>{{scope.row.studentIdName}}</span>
						</template>
						</el-table-column>
						<el-table-column prop="dianming" label="成绩" width="80" show-overflow-tooltip="" >
							<template #default="scope">
								<el-select
									v-model="scope.row.chengji"
									clearable
									placeholder="请选择"
									style="max-width: 70px;"
								>
									<el-option
									v-for="item in chuqianOptions"
									:key="item.value"
									:label="item.label"
									:value="item.value"
									/>
								</el-select>
							</template>
						</el-table-column>
				</el-table>
				</el-col>
			</el-row>
			<template #footer>
				<span class="dialog-footer">
					<el-button type="primary" @click="submit">确 定</el-button>
					<el-button @click="cancel">关闭</el-button>
				</span>
			</template>
		</el-dialog>
	</div>
</template>
<style scoped>
:deep(.el-select),
:deep(.el-input-number) {
	width: 100%;
}
</style>
<script lang="ts" setup>
	import { ref,onMounted } from "vue";
	import { getDictDataItem as di, getDictDataList as dl } from '/@/utils/dict-utils';
	import { ElMessage } from "element-plus";
	import type { FormRules } from "element-plus";
	import { pageListByTeacherId,saveChuqin } from '/@/api/main/myXuanke';
	
	//父级传递来的参数
	var props = defineProps({
		title: {
		type: String,
		default: "",
	},
	});
	//父级传递来的函数，用于回调
	const emit = defineEmits(["reloadTable"]);
	const ruleFormRef = ref();
	const isShowDialog = ref(false);
	const ruleForm = ref<any>({});
	//自行添加其他规则
	const rules = ref<FormRules>({
	});

	const xuankeId = ref(0);
	const tableData = ref<any>([]);
	const loading = ref(false);

	const chuqianOptions = [
	{value: 'A',label: 'A'},
	{value: 'P',label: 'P'},
	{value: 'E',label: 'E'}
	];
	// 打开弹窗
	const openDialog = async (row: any) => {
		xuankeId.value = row.id;
		tableData.value = (await pageListByTeacherId({kechengId:row.id})).data?.result?.items ?? [];
		isShowDialog.value = true;
	};

	// 关闭弹窗
	const closeDialog = () => {
		emit("reloadTable");
		isShowDialog.value = false;
	};

	// 取消
	const cancel = () => {
		isShowDialog.value = false;
		closeDialog();
	};

	// 提交
	const submit = async (data:any) => {
		console.log(tableData.value)
		await saveChuqin({data:tableData.value})
		closeDialog();
	};

	// 页面加载时
	onMounted(async () => {
	});

	//将属性或者函数暴露给父组件
	defineExpose({ openDialog });
</script>




